/**
 * Software License Declaration.
 * <p>
 * zhilingsd.com, Co,. Ltd.
 * Copyright © 2016 All Rights Reserved.
 * <p>
 * Copyright Notice
 * This documents is provided to zhilingsd contracting agent or authorized programmer only.
 * This source code is written and edited by zhilingsd Co,.Ltd Inc specially for financial
 * business contracting agent or authorized cooperative company, in order to help them to
 * install, programme or central control in certain project by themselves independently.
 * <p>
 * Disclaimer
 * If this source code is needed by the one neither contracting agent nor authorized programmer
 * during the use of the code, should contact to zhilingsd Co,. Ltd Inc, and get the confirmation
 * and agreement of three departments managers  - Research Department, Marketing Department and
 * Production Department.Otherwise zhilingsd will charge the fee according to the programme itself.
 * <p>
 * Any one,including contracting agent and authorized programmer,cannot share this code to
 * the third party without the agreement of zhilingsd. If Any problem cannot be solved in the
 * procedure of programming should be feedback to zhilingsd Co,. Ltd Inc in time, Thank you!
 */
package personal.zq.practice.common.utils;

import java.util.Date;
import org.apache.commons.lang.StringUtils;

/**
 * @author yangxianfeng
 * @version 1.0
 * @className CheckNullAndThrowUtil.java
 * @date 2020/11/23 20:06
 */
public class CheckAndThrowUtil {

    public static void checkLen(String value, int len, String errorMsg) {
        if (value.length() > len) {
            throw new BusinessException(errorMsg);
        }
    }

    public static void checkMinLen(String value, int len, String errorMsg) {
        if (value.length() < len) {
            throw new BusinessException(errorMsg);
        }
    }

    public static void checkIsNull(String value, String valueName) {
        if (value == null || StringUtils.isBlank(value.trim())) {
            throw new BusinessException("请输入" + valueName + "信息");
        }
    }


    public static void checkIsNull(Date value, String valueName) {
        if (value == null) {
            throw new BusinessException("请输入" + valueName + "信息");
        }
    }

    public static void checkIsNull(Long value, String valueName) {
        if (value == null) {
            throw new BusinessException("请输入" + valueName + "信息");
        }
    }

    public static void checkIsNull(Integer value, String valueName) {
        if (value == null) {
            throw new BusinessException("请输入" + valueName + "信息");
        }
    }
}